-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ResourceLimiterAsync, which can yield until resource is available #3393
Conversation
Subscribe to Label Actioncc @fitzgen, @peterhuene
This issue or pull request has been labeled: "fuzzing", "wasmtime:api"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
1e14251
to
7d0611b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good to me! If you're up for it I think it would also be interesting to have tests which panic!
in the memory growth (either in the async or sync version) from the custom trait implementation which then asserts that the panic can be caught from the other side of wasm and handled.
edd3b8e
to
d3deaae
Compare
idk why this didnt work in the old factoring! but im glad it does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good to me! A few minor things I might also ask for:
- Doc updates to the blocking methods that they can panic for async stores with an async limiter configured
- Could you add a test where the async-ness is exercised as well? I noticed most of them using the async trait were just async conditions, but could there be one which also sleeps or synchronizes with some other task or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Ok final nit I forgot from earlier, can you add this to the #[cfg]
'd APIs so the feature requirement is rendered with rustdoc? Other than that looks good to go!
#[cfg_attr(nightlydoc, doc(cfg(feature = "async")))]
This PR:
ResourceLimiter
's definition fromwasmtime_runtime
towasmtime
ResourceLimiterAsync
, which is just like aResourceLimiter
except thememory_growing
andtable_growing
methods areasync
(via#[async_trait]
). This is so that async embeddings of wasmtime can handle memory or table growing byawait
ing for a resource to be available.ResourceLimiterAsync
methods to await inside memory & table grows, we need to add async variants ofMemory::new
,Memory::grow
,Table::new
, andTable::grow
. These variants are not required for all asyncStore
s, only for stores which are given aStore::limiter_async
. So, this won't break any existing code.ResourceLimiter
traits now gettable_grow_failed
, which corresponds tomemory_grow_failed
. Better to just get this over with now than have to add it in later.I had to restructure a fair bit of the interface between runtime and wasmtime for this PR, including extending the
wasmtime_runtime::Store
trait, and changing the error type passed between them toanyhow::Error
instead ofBox<dyn std::error::Error + Send + Sync>
.Additionally, both
ResourceLimiter
s are now safer: wasmtime_runtime now catches any panics that occur from the user's impl of the traits.